﻿package mortal.game.view.forging.view
{
    import Message.DB.Tables.*;
    import Message.Game.*;
    import Message.Public.*;
    import com.greensock.*;
    import com.greensock.easing.*;
    import com.greensock.layout.*;
    import com.mui.controls.*;
    import com.mui.utils.*;
    import extend.language.*;
    import fl.data.*;
    import flash.display.*;
    import flash.events.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.common.swfPlayer.*;
    import mortal.common.swfPlayer.data.*;
    import mortal.component.gconst.*;
    import mortal.component.window.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.manager.msgTip.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.utils.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.display.*;
    import mortal.game.view.common.item.*;
    import mortal.game.view.common.menu.*;
    import mortal.game.view.common.util.*;
    import mortal.game.view.forging.*;
    import mortal.game.view.forging.data.*;
    import mortal.game.view.forging.renderer.*;
    import mortal.game.view.palyer.*;
    import mortal.game.view.shop.*;
    import mortal.game.view.systemSetting.*;
    import mortal.mvc.core.*;

    public class StrengthenPanel extends ForgingPanelBase
    {
        private var _bestPreviewLabel:GImageBitmap;
        private var _bestViewEquip:PlayerEquipItem;
        private var _attackArrow:GBitmap;
        private var _attackPerUpValue:GTextFiled;
        private var _critArrow:GBitmap;
        private var _critPerUpValue:GTextFiled;
        private var _accurateArrow:GBitmap;
        private var _accuratePerUpValue:GTextFiled;
        private var _progressBar:BaseProgressBar;
        private var _progressPoint:GBitmap;
        private var _commonStrengBtn:GButton;
        private var _oneKeyStrengBtn:GButton;
        private var _upCostLabel:GTextFiled;
        private var _upCost:GTextFiled;
        private var _goldIcon:GBitmap;
        private var _autoBuyBox:GCheckBox;
        private var _txtEquipCombat:BitmapNumberText;
        private var _txtEquipCombatNew:BitmapNumberText;
        private var _equipCombat:GImageBitmap;
        private var _currPropList:GTileList;
        private var _newPropList:GTileList;
        private var _consumeItem:BaseItem;
        private var _putEquipImg:GImageBitmap;
        private var _reviewText1:GTextFiled;
        private var _reviewText2:GTextFiled;
        private var _equipName:GTextFiled;
        private var _baseAttrTxt:GTextFiled;
        private var _strenAttrTxt:GTextFiled;
        private var _upValueTween1:TweenLite;
        private var _upValueTween11:TweenLite;
        private var _upValueTween2:TweenLite;
        private var _upValueTween22:TweenLite;
        private var _upValueTween3:TweenLite;
        private var _upValueTween33:TweenLite;
        private var _upValueTween4:TweenLite;
        private var _upValueTween44:TweenLite;
        private var _upValueTween5:TweenLite;
        private var _upValueTween55:TweenLite;
        private var _upValueTween6:TweenLite;
        private var _upValueTween66:TweenLite;
        private var _swfPlayer1:SWFPlayer;
        private var _swfPlayer2:SWFPlayer;
        private var _isPlaying1:Boolean;
        private var _isPlaying2:Boolean;
        private var _isCommonStreng:Boolean;
        private var _isMoneyEnough:Boolean = true;
        private var _isPropEnough:Boolean = true;
        private var _needPropNum:int;
        private var _isUpValueAnimating:Boolean;
        private var _isAddFilter:Boolean;

        public function StrengthenPanel(param1:Window)
        {
            super(param1);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.createChildren();
            return;
        }// end function

        override protected function createChildren() : void
        {
            var _loc_1:GTextFormat = null;
            this._bestPreviewLabel = UIFactory.gImageBitmap(ImagesConst.Forging_StrengBestPreview, 6, 55, this);
            this._bestViewEquip = UICompomentPool.getUICompoment(PlayerEquipItem);
            this._bestViewEquip.setItemStyle(ItemStyleConst.Small, ImagesConst.EquipItemBg, 5, 5);
            this._bestViewEquip.x = 12;
            this._bestViewEquip.y = 10;
            this.addChild(this._bestViewEquip);
            this._bestViewEquip.isShowArroundEffect = false;
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.EquipStrengPart, 25, 11, this));
            this.pushUIToDisposeVec(UIFactory.gBitmap(ImagesConst.TextBg3, 157 - 25, 1, this));
            _loc_1 = GlobalStyle.textFormatBai;
            _loc_1.align = AlignMode.CENTER;
            this._equipName = UIFactory.gTextField("", 128, 7, 234, 20, this, _loc_1);
            this._equipName.htmlText = Language.getString(40101);
            _currOperEquip = UICompomentPool.getUICompoment(PlayerEquipItem);
            _currOperEquip.setItemStyle(ItemStyleConst.Big, "", 0, 0);
            _currOperEquip.x = 213;
            _currOperEquip.y = 74;
            this.addChild(_currOperEquip);
            _currOperEquip.isShowArroundEffect = false;
            _currOperEquip.configEventListener(MouseEvent.CLICK, onEquipClickHandler);
            this._putEquipImg = UIFactory.gImageBitmap(ImagesConst.Forging_PutInEquip, 225, 81, this);
            this.pushUIToDisposeVec(UIFactory.bg(104 + 15, 190, 284 - 29, 130, this, ImagesConst.AttributeBg));
            this._baseAttrTxt = UIFactory.gTextField(Language.getString(41193), 159 + 15, 196, 65, 30, this, GlobalStyle.textFormatHuang);
            this._baseAttrTxt.toolTipData = Language.getString(41194);
            this._strenAttrTxt = UIFactory.gTextField(Language.getString(41195), 299 - 29 + 15, 196, 75, 30, this, GlobalStyle.textFormatChen);
            this._strenAttrTxt.toolTipData = Language.getString(41196);
            this.pushUIToDisposeVec(UIFactory.bg(114 + 15, 218, 274 - 29, 23, this, ImagesConst.RegionTitleBg));
            this._equipCombat = UIFactory.gImageBitmap(ImagesConst.Forging_Text_EquipCombat, 141 + 15, 221, this);
            this._reviewText1 = UIFactory.gTextField(Language.getString(41197), 198 + 15, 219, 100, 20, this, GlobalStyle.textFormatHuang);
            this._txtEquipCombat = UIFactory.bitmapNumberText(198 + 15, 222, "FightInfoNum.png", 12, 15, -1, this);
            this._reviewText2 = UIFactory.gTextField(Language.getString(41197), 294 - 25 + 15, 219, 100, 20, this, GlobalStyle.textFormatHuang);
            this._txtEquipCombatNew = UIFactory.bitmapNumberText(299 - 29 + 15, 222, "FightInfoNum.png", 12, 15, -1, this);
            this._currPropList = UIFactory.tileList(152 + 15, 241, 96, 75, this);
            this._currPropList.columnWidth = 95;
            this._currPropList.rowHeight = 22;
            this._currPropList.horizontalGap = 0;
            this._currPropList.verticalGap = 0;
            this._currPropList.setStyle("skin", new Bitmap());
            this._currPropList.setStyle("cellRenderer", StrengthenPropCellRenderer);
            this._newPropList = UIFactory.tileList(326 - 27 - 29 + 15, 241, 96, 75, this);
            this._newPropList.columnWidth = 95;
            this._newPropList.rowHeight = 22;
            this._newPropList.horizontalGap = 0;
            this._newPropList.verticalGap = 0;
            this._newPropList.setStyle("skin", new Bitmap());
            this._newPropList.setStyle("cellRenderer", StrengthenPropCellRenderer);
            this._attackArrow = UIFactory.gBitmap(ImagesConst.upgradeArrow, 421 - 64 - 14, 246, this);
            this._attackArrow.alpha = 0;
            this._attackPerUpValue = UIFactory.gTextField("", 434 - 64 - 14, 242, 40, 20, this, GlobalStyle.textFormatLv);
            this._attackPerUpValue.alpha = 0;
            this._critPerUpValue = UIFactory.gTextField("", 434 - 64 - 14, 259 + 5, 40, 20, this, GlobalStyle.textFormatLv);
            this._critPerUpValue.alpha = 0;
            this._critArrow = UIFactory.gBitmap(ImagesConst.upgradeArrow, 421 - 64 - 14, 263 + 5, this);
            this._critArrow.alpha = 0;
            this._accuratePerUpValue = UIFactory.gTextField("", 434 - 64 - 14, 279 + 6, 40, 20, this, GlobalStyle.textFormatLv);
            this._accuratePerUpValue.alpha = 0;
            this._accurateArrow = UIFactory.gBitmap(ImagesConst.upgradeArrow, 421 - 64 - 14, 283 + 6, this);
            this._accurateArrow.alpha = 0;
            this._progressBar = UICompomentPool.getUICompoment(BaseProgressBar);
            this._progressBar.setBg(ImagesConst.StrengthenBarBg2, true, 268, 13);
            this._progressBar.setProgress(ImagesConst.StrengthenBar2, true, 14, 1, 240, 12);
            this._progressBar.setLabel(BaseProgressBar.ProgressBarTextPercent, 270 - 150, -4, 35, 20, GlobalStyle.textFormatHuang);
            this._progressBar.setValue(0, 10000);
            this._progressBar.x = 126;
            this._progressBar.y = 339;
            this.addChild(this._progressBar);
            this._progressPoint = UIFactory.gBitmap(ImagesConst.StrengthenBarPoint2, 0, -8 - 4, this._progressBar);
            this.updateProgressBar(0, 100);
            this.pushUIToDisposeVec(UIFactory.gTextField(Language.getString(41198), 61, 302, 70, 20, this, _loc_1));
            this._consumeItem = UICompomentPool.getUICompoment(BaseItem);
            this._consumeItem.setItemStyle(ItemStyleConst.Small, ImagesConst.PackItemBg, 2, 2);
            this._consumeItem.x = 76;
            this._consumeItem.y = 324;
            this.addChild(this._consumeItem);
            this._commonStrengBtn = UIFactory.gButton(Language.getString(41199), 157, 369, 82, 28, this, "BrownBtn");
            this._commonStrengBtn.name = "Forging_commonStrengBtn";
            this._commonStrengBtn.mouseChildren = false;
            this._commonStrengBtn.toolTipData = Language.getString(41200);
            this._oneKeyStrengBtn = UIFactory.gButton(Language.getString(41201), 263, 369, 82, 28, this, "BrownBtn");
            this._oneKeyStrengBtn.mouseChildren = false;
            this._oneKeyStrengBtn.toolTipData = Language.getString(41202);
            this._commonStrengBtn.configEventListener(MouseEvent.CLICK, this.onClickHandler);
            this._oneKeyStrengBtn.configEventListener(MouseEvent.CLICK, this.onClickHandler);
            this._upCostLabel = UIFactory.gTextField(Language.getString(41203), 95, 410, 87, 20, this, GlobalStyle.textFormatHuang);
            this._upCost = UIFactory.gTextField("", 179, 410, 40, 20, this, GlobalStyle.textFormatHuang);
            this._goldIcon = UIFactory.gBitmap(ImagesConst.Jinbi_bind, 211, 409, this);
            this._autoBuyBox = UIFactory.checkBox(Language.getString(41204), 356, 402 + 5, 140, 28, this);
            this._autoBuyBox.configEventListener(MouseEvent.CLICK, this.onClickHandler);
            this._swfPlayer1 = UICompomentPool.getUICompoment(SWFPlayer);
            this._swfPlayer2 = UICompomentPool.getUICompoment(SWFPlayer);
            this.canBeStrengthened = false;
            addEquipListeners();
            this.judgeSmallIcon();
            return;
        }// end function

        private function judgeSmallIcon() : void
        {
            if (!StrengthenIcon.instance.isHide)
            {
                StrengthenIcon.instance.hide();
            }
            return;
        }// end function

        override public function updateUI() : void
        {
            var _loc_2:ItemData = null;
            var _loc_4:int = 0;
            var _loc_5:int = 0;
            var _loc_1:int = 0;
            while (_loc_1 < 3)
            {
                
                _loc_4 = 128 + 15;
                _loc_5 = 261 + _loc_1 % 3 * 22;
                this.pushUIToDisposeVec(UIFactory.bg(_loc_4, _loc_5, 243 - 29, 0, this, ImagesConst.PropSplitLine));
                _loc_1++;
            }
            if (ClientSetting.local.getIsDone(IsDoneType.AutoBuyStrengProp))
            {
                this.autoBuyBox.selected = true;
            }
            else
            {
                this.autoBuyBox.selected = false;
            }
            var _loc_3:* = Cache.instance.pack.packRolePackCache.getEquipByType(EEquip._EEquipWeapon);
            if (GameController.autoGuide.isGuidingQH() && _loc_3)
            {
                _loc_2 = _loc_3;
            }
            else
            {
                _loc_2 = Cache.instance.pack.packRolePackCache.getBestRecommendEquip();
            }
            Dispatcher.dispatchEvent(new DataEvent(EventName.ForgingSelDefaultEquip, _loc_2));
            return;
        }// end function

        override public function addForgingEquip(param1:PlayerEquipItem) : void
        {
            var _loc_2:int = 0;
            var _loc_3:int = 0;
            var _loc_4:Array = null;
            var _loc_5:Object = null;
            super.addForgingEquip(param1);
            if (param1 && param1.itemData)
            {
                this.stopAllStrengthenEffect();
                _loc_2 = param1.itemData.extInfo.strengthen;
                _loc_3 = param1.itemData.extInfo.currentStrengthen;
                if (_loc_2 == ForgingConst.MaxStrengLevel)
                {
                    this.canBeStrengthened = false;
                }
                else
                {
                    this.canBeStrengthened = true;
                }
                if (Cache.instance.forging.getEquipByUid(param1.itemData.uid) == null)
                {
                    Cache.instance.forging.addStrengthenEquip(param1);
                }
                this.addStrengEquip(param1);
                _loc_4 = EquipBasePropUtil.instance.getStrengthenProps2(param1.itemData);
                this.updateEquipProp(_loc_4);
                this.updateProgressBar(_loc_3, ForgingConst.TotalStrengProgress);
                Cache.instance.forging.currStrengValue = [];
                for each (_loc_5 in _loc_4)
                {
                    
                    Cache.instance.forging.currStrengValue.push(_loc_5.propStrengValue);
                }
                this.updateConsumes();
            }
            return;
        }// end function

        override public function updateForgingInfo() : void
        {
            _currOperEquip.updateStrengLevel();
            this.updateConsumes();
            this.updateEquipNameInfo();
            var _loc_1:* = _currOperEquip.itemData.extInfo.strengthen;
            if (_loc_1 == ForgingConst.MaxStrengLevel)
            {
                this.canBeStrengthened = false;
            }
            else
            {
                this.canBeStrengthened = true;
            }
            return;
        }// end function

        private function updateConsumes() : void
        {
            this.updateFee();
            this.updateConsumeItem();
            return;
        }// end function

        public function updateProgressBar(param1:Number, param2:Number) : void
        {
            if (_disposed)
            {
                return;
            }
            this._progressBar.setValue(param1, param2);
            this._progressPoint.x = this._progressBar.lastWidth + 7;
            if (param1 == 0)
            {
                this._progressPoint.visible = false;
            }
            else
            {
                this._progressPoint.visible = true;
            }
            return;
        }// end function

        private function onClickHandler(event:MouseEvent) : void
        {
            var _loc_3:ItemInfo = null;
            var _loc_4:int = 0;
            var _loc_5:Boolean = false;
            var _loc_2:Object = {};
            if (event.target == this._commonStrengBtn)
            {
                if (_currOperEquip.itemData)
                {
                    _loc_2.uid = _currOperEquip.itemData.uid;
                    if (this._isPlaying1 || this._isPlaying2)
                    {
                        this.stopAllStrengthenEffect();
                    }
                    if (!this._isMoneyEnough)
                    {
                        this.showBuyMoneyTipWin();
                        return;
                    }
                    if (this._isPropEnough)
                    {
                        _loc_2.strengType = EOperType._EOperTypeSimple;
                        Dispatcher.dispatchEvent(new DataEvent(EventName.EquipStrengthen, _loc_2));
                    }
                    else
                    {
                        _loc_3 = this._consumeItem.itemData.itemInfo;
                        _loc_4 = ShopConfig.instance.getFastBuyItemByCode(_loc_3.bind ? (_loc_3.codeUnbind) : (_loc_3.code)).prize * this._needPropNum;
                        _loc_5 = Cache.instance.role.enoughMoney(EPriceUnit._EPriceUnitGoldBind, _loc_4, null, false);
                        if (this._autoBuyBox.selected)
                        {
                            if (_loc_5)
                            {
                                _loc_2.strengType = EOperType._EOperTypeSimple;
                                Dispatcher.dispatchEvent(new DataEvent(EventName.EquipStrengthen, _loc_2));
                            }
                            else
                            {
                                this.showGiftToUse(_loc_3, this._needPropNum);
                            }
                        }
                        else
                        {
                            this.showGiftToUse(_loc_3, this._needPropNum);
                        }
                    }
                    if (this._isAddFilter)
                    {
                        this._isAddFilter = false;
                        EffectManager.glowFilterUnReg(this._commonStrengBtn);
                    }
                }
            }
            if (event.target == this._oneKeyStrengBtn)
            {
                if (_currOperEquip.itemData)
                {
                    _loc_2.uid = this._currOperEquip.itemData.uid;
                    if (this._isPlaying1 || this._isPlaying2)
                    {
                        this.stopAllStrengthenEffect();
                    }
                    if (!this._isMoneyEnough)
                    {
                        this.showBuyMoneyTipWin();
                        return;
                    }
                    if (this._isPropEnough)
                    {
                        _loc_2.strengType = EOperType._EoperTypeBatch;
                        Dispatcher.dispatchEvent(new DataEvent(EventName.EquipStrengthen, _loc_2));
                    }
                    else
                    {
                        _loc_3 = this._consumeItem.itemData.itemInfo;
                        _loc_4 = ShopConfig.instance.getFastBuyItemByCode(_loc_3.bind ? (_loc_3.codeUnbind) : (_loc_3.code)).prize * this._needPropNum;
                        _loc_5 = Cache.instance.role.enoughMoney(EPriceUnit._EPriceUnitGoldBind, _loc_4, null, false);
                        if (this._autoBuyBox.selected)
                        {
                            if (_loc_5)
                            {
                                _loc_2.strengType = EOperType._EoperTypeBatch;
                                Dispatcher.dispatchEvent(new DataEvent(EventName.EquipStrengthen, _loc_2));
                            }
                            else
                            {
                                this.showGiftToUse(_loc_3, this._needPropNum);
                            }
                        }
                        else
                        {
                            this.showGiftToUse(_loc_3, this._needPropNum);
                        }
                    }
                    if (this._isAddFilter)
                    {
                        this._isAddFilter = false;
                        EffectManager.glowFilterUnReg(this._commonStrengBtn);
                    }
                }
            }
            if (event.target == this._autoBuyBox)
            {
                if (this._autoBuyBox.selected == true)
                {
                    ClientSetting.local.setIsDone(true, IsDoneType.AutoBuyStrengProp);
                }
                else
                {
                    ClientSetting.local.setIsDone(false, IsDoneType.AutoBuyStrengProp);
                }
            }
            return;
        }// end function

        private function showGiftToUse(param1:ItemInfo, param2:int) : void
        {
            if (GiftsUtil.isCanUseFreeGift(param1.group, param1.category, param1.type))
            {
                MsgManager.showRollTipsMsg(Language.getString(41205));
                return;
            }
            if (BuyGiftItemWin.isAutoBuy)
            {
                BuyGiftItemWin.isNeedTobuyCurTime = true;
                NetDispatcher.addCmdListener(ServerCommand.BackPackItemsAdd, this.keepLevelUp);
            }
            else
            {
                MsgManager.showMouseMsg(Language.getString(41206), MsgRollTipsType.msgRollTips3);
            }
            BuyGiftItemWin.instance.setBuyData(param1.code, 1, param2, _window.x + _window.width + 5, _window.y - 3);
            return;
        }// end function

        private function keepLevelUp(param1:Array) : void
        {
            var _loc_2:* = param1[0] as ItemData;
            if (ItemsUtil.isStrengthTone(_loc_2))
            {
                NetDispatcher.removeCmdListener(ServerCommand.BackPackItemsAdd, this.keepLevelUp);
            }
            return;
        }// end function

        private function showBuyMoneyTipWin() : void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.ShowBindCoinPackWin));
            return;
        }// end function

        public function displayUpValue(param1:Array) : void
        {
            if (param1 != null)
            {
                if (param1[0] != 0)
                {
                    this._attackPerUpValue.text = param1[0] + "";
                    this._upValueTween1 = TweenLite.to(this._attackArrow, 0.5, {alpha:1, ease:Linear.easeNone, onComplete:this.onShowEnd, onCompleteParams:[0]});
                    this._upValueTween11 = TweenLite.to(this._attackPerUpValue, 0.5, {alpha:1, ease:Linear.easeNone, onComplete:this.onShowEnd, onCompleteParams:[0]});
                }
                if (param1[1] != 0)
                {
                    this._critPerUpValue.text = param1[1] + "";
                    this._upValueTween2 = TweenLite.to(this._critArrow, 0.5, {alpha:1, ease:Linear.easeNone, onComplete:this.onShowEnd, onCompleteParams:[1]});
                    this._upValueTween22 = TweenLite.to(this._critPerUpValue, 0.5, {alpha:1, ease:Linear.easeNone, onComplete:this.onShowEnd, onCompleteParams:[1]});
                }
                if (param1[2] != 0)
                {
                    this._accuratePerUpValue.text = param1[2] + "";
                    this._upValueTween3 = TweenLite.to(this._accurateArrow, 0.5, {alpha:1, ease:Linear.easeNone, onComplete:this.onShowEnd, onCompleteParams:[2]});
                    this._upValueTween33 = TweenLite.to(this._accuratePerUpValue, 0.5, {alpha:1, ease:Linear.easeNone, onComplete:this.onShowEnd, onCompleteParams:[2]});
                }
            }
            return;
        }// end function

        private function onShowEnd(param1:int) : void
        {
            switch(param1)
            {
                case 0:
                {
                    this._upValueTween4 = TweenLite.to(this._attackArrow, 0.5, {alpha:0, ease:Linear.easeNone});
                    this._upValueTween44 = TweenLite.to(this._attackPerUpValue, 0.5, {alpha:0, ease:Linear.easeNone});
                    break;
                }
                case 1:
                {
                    this._upValueTween5 = TweenLite.to(this._critArrow, 0.5, {alpha:0, ease:Linear.easeNone});
                    this._upValueTween55 = TweenLite.to(this._critPerUpValue, 0.5, {alpha:0, ease:Linear.easeNone});
                    break;
                }
                case 2:
                {
                    this._upValueTween6 = TweenLite.to(this._accurateArrow, 0.5, {alpha:0, ease:Linear.easeNone});
                    this._upValueTween66 = TweenLite.to(this._accuratePerUpValue, 0.5, {alpha:0, ease:Linear.easeNone});
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        public function addStrengEquip(param1:PlayerEquipItem) : void
        {
            _currOperEquip.itemData = param1.itemData;
            _currOperEquip.updateStrengLevel();
            this.updateBestEquip();
            this.updateConsumeItem();
            this.updateBaseCombat();
            this.updateStrengCombat();
            this.updateEquipNameInfo();
            if (this._putEquipImg.visible)
            {
                this._putEquipImg.visible = false;
            }
            if (this._reviewText1.visible)
            {
                this._reviewText1.visible = false;
            }
            if (this._reviewText2.visible)
            {
                this._reviewText2.visible = false;
            }
            return;
        }// end function

        public function updateBestEquip() : void
        {
            var _loc_2:int = 0;
            var _loc_1:* = new ItemData(_currOperEquip.itemData.itemCode, true);
            _loc_1.extInfo = _currOperEquip.itemData.extInfo.clone();
            var _loc_3:* = _currOperEquip.itemData.extInfo.strengthen;
            if (_loc_3 <= 5)
            {
                _loc_2 = 6;
            }
            else if (_loc_3 <= 8)
            {
                _loc_2 = 9;
            }
            else if (_loc_3 <= 11)
            {
                _loc_2 = 12;
            }
            else if (_loc_3 <= ForgingConst.MaxStrengLevel)
            {
                _loc_2 = ForgingConst.MaxStrengLevel;
            }
            _loc_1.extInfo.strengthen = _loc_2;
            _loc_1.extInfo.currentStrengthen = 0;
            _loc_1.extInfo.combat = EquipmentUtil.getEquipCombat(_loc_1);
            this._bestViewEquip.itemData = _loc_1;
            this._bestViewEquip.updateStrengLevel();
            this.updateGemHole(_loc_1);
            _loc_1.extData = _loc_1.extInfo;
            return;
        }// end function

        private function updateEquipNameInfo() : void
        {
            this._equipName.htmlText = ItemsUtil.getItemWholeName(_currOperEquip.itemData, true, 1, false);
            return;
        }// end function

        private function updateGemHole(param1:ItemData) : void
        {
            var _loc_3:int = 0;
            var _loc_2:* = _currOperEquip.itemData.extInfo.strengthen;
            if (_loc_2 < 3)
            {
                _loc_3 = 3;
            }
            else if (_loc_2 < 6)
            {
                _loc_3 = 2;
            }
            else if (_loc_2 < 9)
            {
                _loc_3 = 1;
            }
            var _loc_4:int = 1;
            while (_loc_4 <= 8)
            {
                
                if (param1.extInfo["h" + _loc_4] == null && _loc_3 != 0)
                {
                    param1.extInfo["h" + _loc_4] = "0";
                    _loc_3 = _loc_3 - 1;
                    (param1.extInfo.hole_num + 1);
                }
                _loc_4++;
            }
            return;
        }// end function

        private function updateBaseCombat() : void
        {
            var _loc_1:* = new ItemData(_currOperEquip.itemData.itemCode, true);
            _loc_1.extInfo = _currOperEquip.itemData.extInfo.clone();
            _loc_1.extInfo.strengthen = 0;
            _loc_1.extInfo.currentStrengthen = 0;
            _loc_1.extInfo.qual = 0;
            this._txtEquipCombat.text = "" + EquipmentUtil.getEquipCombat(_loc_1);
            return;
        }// end function

        public function updateStrengCombat() : void
        {
            var _loc_1:* = new ItemData(_currOperEquip.itemData.itemCode, true);
            _loc_1.extInfo = _currOperEquip.itemData.extInfo.clone();
            _loc_1.extInfo.strengthen = 0;
            _loc_1.extInfo.currentStrengthen = 0;
            var _loc_2:* = _currOperEquip.itemData.extInfo.combat;
            var _loc_3:* = _loc_2 - EquipmentUtil.getEquipCombat(_loc_1);
            if (_loc_3 < 0)
            {
                _loc_3 = 0;
            }
            this._txtEquipCombatNew.text = "+" + _loc_3;
            return;
        }// end function

        private function updateConsumeItem() : void
        {
            var _loc_2:int = 0;
            var _loc_3:int = 0;
            var _loc_4:ItemData = null;
            var _loc_1:* = _currOperEquip.itemData.extInfo.strengthen;
            if (_loc_1 < ForgingConst.MaxStrengLevel)
            {
                _loc_2 = EquipStrengthenConfig.instance.getInfoByLevel((_loc_1 + 1)).consumeItemCode;
                _loc_3 = EquipStrengthenConfig.instance.getInfoByLevel((_loc_1 + 1)).consumeItemAmount;
                _loc_4 = new ItemData(_loc_2);
                this._consumeItem.itemData = _loc_4;
                this._consumeItem.amount = _loc_3;
                ItemMenuRegister.unRegister(this._consumeItem);
                this._consumeItem.doubleClickEnabled = false;
                this.updateConsumeState();
            }
            return;
        }// end function

        override public function updateConsumeState() : void
        {
            var _loc_1:int = 0;
            var _loc_2:int = 0;
            var _loc_3:int = 0;
            var _loc_4:int = 0;
            if (_currOperEquip.itemData && this._consumeItem.itemData)
            {
                _loc_1 = this._consumeItem.itemData.itemInfo.type;
                _loc_2 = _currOperEquip.itemData.extInfo.strengthen;
                if (_loc_2 == ForgingConst.MaxStrengLevel)
                {
                    return;
                }
                _loc_3 = EquipStrengthenConfig.instance.getInfoByLevel((_loc_2 + 1)).consumeItemAmount;
                _loc_4 = Cache.instance.pack.backPackCache.getItemCountByItemData(this._consumeItem.itemData);
                if (_loc_3 <= _loc_4)
                {
                    this._consumeItem.isGray = false;
                    this._isPropEnough = true;
                }
                else
                {
                    this._consumeItem.isGray = true;
                    this._isPropEnough = false;
                    this._needPropNum = _loc_3 - _loc_4;
                }
            }
            return;
        }// end function

        override public function updateMoneyState() : void
        {
            this.updateFee();
            return;
        }// end function

        public function updateEquipProp(param1:Array) : void
        {
            var _loc_4:Object = null;
            var _loc_5:Object = null;
            var _loc_2:* = new DataProvider();
            var _loc_3:* = new DataProvider();
            var _loc_6:int = 0;
            while (_loc_6 < param1.length)
            {
                
                _loc_4 = new Object();
                _loc_5 = new Object();
                _loc_4.attrName = param1[_loc_6].attrName;
                _loc_4.propName = param1[_loc_6].propName;
                _loc_4.propBaseValue = param1[_loc_6].propBaseValue;
                _loc_5.attrName = param1[_loc_6].attrName;
                _loc_5.propName = param1[_loc_6].propName;
                _loc_5.propStrengValue = param1[_loc_6].propStrengValue;
                _loc_2.addItem(_loc_4);
                _loc_3.addItem(_loc_5);
                _loc_6++;
            }
            this._currPropList.dataProvider = _loc_2;
            this._newPropList.dataProvider = _loc_3;
            this._currPropList.drawNow();
            this._newPropList.drawNow();
            return;
        }// end function

        public function updateFee() : void
        {
            var _loc_1:int = 0;
            var _loc_2:int = 0;
            var _loc_3:TEquipStrengthen = null;
            if (_currOperEquip.itemData)
            {
                _loc_2 = _currOperEquip.itemData.extInfo.strengthen;
                if (_loc_2 < ForgingConst.MaxStrengLevel)
                {
                    _loc_3 = EquipStrengthenConfig.instance.getInfoByLevel((_loc_2 + 1));
                    _loc_1 = _loc_3.consumeMoney;
                    this._upCost.text = "" + _loc_1;
                    if (_loc_1 > Cache.instance.role.money.coin + Cache.instance.role.money.coinBind)
                    {
                        this._upCost.textColor = GlobalStyle.colorHongUint;
                        this._isMoneyEnough = false;
                    }
                    else
                    {
                        this._upCost.textColor = GlobalStyle.colorHuangUint;
                        this._isMoneyEnough = true;
                    }
                }
                else
                {
                    this._upCost.text = "";
                }
            }
            return;
        }// end function

        public function set canBeStrengthened(param1:Boolean) : void
        {
            if (param1)
            {
                this._commonStrengBtn.mouseEnabled = true;
                this._commonStrengBtn.filters = null;
                this._oneKeyStrengBtn.mouseEnabled = true;
                this._oneKeyStrengBtn.filters = null;
            }
            else
            {
                this._commonStrengBtn.mouseEnabled = false;
                this._commonStrengBtn.filters = [FilterConst.colorFilter2];
                this._oneKeyStrengBtn.mouseEnabled = false;
                this._oneKeyStrengBtn.filters = [FilterConst.colorFilter2];
            }
            return;
        }// end function

        private function addStrengFilterEffect() : void
        {
            var _loc_5:StrengthenPropCellRenderer = null;
            var _loc_1:int = 0;
            while (_loc_1 < this._newPropList.length)
            {
                
                _loc_5 = this._newPropList.itemToCellRenderer(this._newPropList.getItemAt(_loc_1)) as StrengthenPropCellRenderer;
                if (_loc_5)
                {
                    _loc_5.addTextEffect();
                }
                _loc_1++;
            }
            var _loc_2:Array = [FilterConst.colorGlowFilter(GlobalStyle.colorHuang2Uint)];
            EffectManager.glowFilterUnReg(this._txtEquipCombatNew);
            EffectManager.glowFilterReg(this._txtEquipCombatNew, _loc_2, 1, 10, 0, 3);
            var _loc_3:Array = [FilterConst.colorGlowFilter(11252925)];
            var _loc_4:Array = [FilterConst.colorGlowFilter(11252925), FilterConst.colorGlowFilter(GlobalStyle.colorHuangUint)];
            EffectManager.glowFilterUnReg(this._progressBar);
            EffectManager.glowFilterReg(this._progressBar, _loc_3, 1, 10, 0, 1);
            EffectManager.glowFilterUnReg(_currOperEquip);
            EffectManager.glowFilterReg(_currOperEquip, _loc_4, 1, 30, 0, 1);
            return;
        }// end function

        private function stopStrengFilterEffect() : void
        {
            var _loc_2:StrengthenPropCellRenderer = null;
            var _loc_1:int = 0;
            while (_loc_1 < this._newPropList.length)
            {
                
                _loc_2 = this._newPropList.itemToCellRenderer(this._newPropList.getItemAt(_loc_1)) as StrengthenPropCellRenderer;
                if (_loc_2)
                {
                    _loc_2.stopTextEffect();
                }
                _loc_1++;
            }
            EffectManager.glowFilterUnReg(this._txtEquipCombatNew);
            EffectManager.glowFilterUnReg(this._progressBar);
            EffectManager.glowFilterUnReg(_currOperEquip);
            return;
        }// end function

        public function addStrengUpEffect() : void
        {
            _currOperEquip.updateStrengLevel();
            _currOperEquip.addStrengUpEffect();
            return;
        }// end function

        public function playStrengthenEffect() : void
        {
            var _loc_1:String = null;
            var _loc_2:String = null;
            if (_currOperEquip.itemData)
            {
                this._isCommonStreng = _currOperEquip.itemData.extInfo.currentStrengthen == 0 ? (false) : (true);
            }
            if (!this._isPlaying1 && !this._isPlaying2)
            {
                _loc_1 = this._isCommonStreng == true ? ("StrengUpCommonEffect.swf") : ("StrengUpPerfectEffect.swf");
                _loc_2 = this._isCommonStreng == true ? ("StrengDownCommonEffect.swf") : ("StrengDownPerfectEffect.swf");
                this._swfPlayer1.move(250 - 5, 107);
                this._swfPlayer1.load(_loc_1, ModelType.NormalSwf, null);
                this._swfPlayer1.framesPlayerCompleteHandler = this.firstEffectEndHandler;
                this.addChild(this._swfPlayer1);
                this._isPlaying1 = true;
                if (this._isCommonStreng)
                {
                    this._swfPlayer2.move(226 + 30, 300 + 47);
                }
                else
                {
                    this._swfPlayer2.move(226 + 43, 300 + 39);
                }
                this._swfPlayer2.load(_loc_2, ModelType.NormalSwf, null);
                this._swfPlayer2.framesPlayerCompleteHandler = this.secondEffectEndHandler;
                this.addChild(this._swfPlayer2);
                this._isPlaying2 = true;
            }
            return;
        }// end function

        private function firstEffectEndHandler(param1:SWFPlayer) : void
        {
            this._swfPlayer1.framesPlayerCompleteHandler = null;
            this._swfPlayer1.stop();
            DisplayUtil.removeMe(this._swfPlayer1);
            this._isPlaying1 = false;
            this.addStrengFilterEffect();
            return;
        }// end function

        private function secondEffectEndHandler(param1:SWFPlayer) : void
        {
            this._swfPlayer2.framesPlayerCompleteHandler = null;
            this._swfPlayer2.stop();
            DisplayUtil.removeMe(this._swfPlayer2);
            this._isPlaying2 = false;
            return;
        }// end function

        public function stopAllStrengthenEffect() : void
        {
            if (this._isPlaying1)
            {
                this._swfPlayer1.stop();
                DisplayUtil.removeMe(this._swfPlayer1);
                this._isPlaying1 = false;
            }
            if (this._isPlaying2)
            {
                this._swfPlayer2.stop();
                DisplayUtil.removeMe(this._swfPlayer2);
                this._isPlaying2 = false;
            }
            this.stopStrengFilterEffect();
            this.killTween();
            return;
        }// end function

        override public function clearUI() : void
        {
            var _loc_1:* = new DataProvider();
            var _loc_2:* = new DataProvider();
            this._currPropList.dataProvider = _loc_1;
            this._newPropList.dataProvider = _loc_2;
            this.updateProgressBar(0, ForgingConst.TotalStrengProgress);
            this.canBeStrengthened = false;
            this._putEquipImg.visible = true;
            this._reviewText1.visible = true;
            this._reviewText2.visible = true;
            _currOperEquip.itemData = null;
            this._bestViewEquip.itemData = null;
            this._consumeItem.itemData = null;
            this._txtEquipCombat.text = "";
            this._txtEquipCombatNew.text = "";
            this._equipName.text = "";
            this._upCost.text = "";
            _currOperEquip.updateStrengLevel();
            this._bestViewEquip.updateStrengLevel();
            return;
        }// end function

        private function killTween() : void
        {
            if (this._upValueTween1)
            {
                this._upValueTween1.kill();
                this._upValueTween11.kill();
            }
            if (this._upValueTween2)
            {
                this._upValueTween2.kill();
                this._upValueTween22.kill();
            }
            if (this._upValueTween3)
            {
                this._upValueTween3.kill();
                this._upValueTween33.kill();
            }
            if (this._upValueTween4)
            {
                this._upValueTween4.kill();
                this._upValueTween44.kill();
            }
            if (this._upValueTween5)
            {
                this._upValueTween5.kill();
                this._upValueTween55.kill();
            }
            if (this._upValueTween6)
            {
                this._upValueTween6.kill();
                this._upValueTween66.kill();
            }
            this._attackArrow.alpha = 0;
            this._attackPerUpValue.alpha = 0;
            this._critArrow.alpha = 0;
            this._critPerUpValue.alpha = 0;
            this._accurateArrow.alpha = 0;
            this._accuratePerUpValue.alpha = 0;
            return;
        }// end function

        public function addBtnFilter() : void
        {
            this._isAddFilter = true;
            EffectManager.glowFilterReg(this._commonStrengBtn);
            return;
        }// end function

        public function get autoBuyBox() : GCheckBox
        {
            return this._autoBuyBox;
        }// end function

        public function get isPlaying1() : Boolean
        {
            return this._isPlaying1;
        }// end function

        public function get isPlaying2() : Boolean
        {
            return this._isPlaying2;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            NetDispatcher.removeCmdListener(ServerCommand.BackPackItemsAdd, this.keepLevelUp);
            this.killTween();
            this._commonStrengBtn.name = "";
            super.disposeImpl(param1);
            this._bestPreviewLabel.dispose(param1);
            this._attackArrow.dispose(param1);
            this._critArrow.dispose(param1);
            this._accurateArrow.dispose(param1);
            this._progressBar.dispose(param1);
            this._progressPoint.dispose(param1);
            this._commonStrengBtn.dispose(param1);
            this._oneKeyStrengBtn.dispose(param1);
            this._upCostLabel.dispose(param1);
            this._upCost.dispose(param1);
            this._goldIcon.dispose(param1);
            this._autoBuyBox.dispose(param1);
            this._attackPerUpValue.dispose(param1);
            this._critPerUpValue.dispose(param1);
            this._accuratePerUpValue.dispose(param1);
            this._bestViewEquip.dispose(param1);
            _currOperEquip.dispose(param1);
            this._txtEquipCombat.dispose(param1);
            this._txtEquipCombatNew.dispose(param1);
            this._equipCombat.dispose(param1);
            this._currPropList.dispose(param1);
            this._newPropList.dispose(param1);
            this._consumeItem.dispose(param1);
            this._putEquipImg.dispose(param1);
            this._reviewText1.dispose(param1);
            this._reviewText2.dispose(param1);
            this._equipName.dispose(param1);
            this._swfPlayer1.dispose(param1);
            this._swfPlayer2.dispose(param1);
            this._baseAttrTxt.dispose();
            this._strenAttrTxt.dispose();
            this._bestPreviewLabel = null;
            this._attackArrow = null;
            this._critArrow = null;
            this._accurateArrow = null;
            this._progressBar = null;
            this._progressPoint = null;
            this._commonStrengBtn = null;
            this._oneKeyStrengBtn = null;
            this._upCostLabel = null;
            this._upCost = null;
            this._goldIcon = null;
            this._autoBuyBox = null;
            this._attackPerUpValue = null;
            this._critPerUpValue = null;
            this._accuratePerUpValue = null;
            this._bestViewEquip = null;
            _currOperEquip = null;
            this._txtEquipCombat = null;
            this._txtEquipCombatNew = null;
            this._equipCombat = null;
            this._currPropList = null;
            this._newPropList = null;
            this._consumeItem = null;
            this._putEquipImg = null;
            this._reviewText1 = null;
            this._reviewText2 = null;
            this._equipName = null;
            this._baseAttrTxt = null;
            this._strenAttrTxt = null;
            this._swfPlayer1 = null;
            this._swfPlayer2 = null;
            this._isPlaying1 = false;
            this._isPlaying2 = false;
            this._isAddFilter = false;
            this._isMoneyEnough = true;
            this._isPropEnough = true;
            this._needPropNum = 0;
            EffectManager.glowFilterUnReg(this._commonStrengBtn);
            removeEquipListeners();
            return;
        }// end function

    }
}
